﻿using Admin.Core;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Threading.Tasks;

namespace Admin.Core
{
    /// <summary>
    /// 请求日志
    /// </summary>
    public class LogHandler: ActionFilterAttribute
    {
        private readonly IOperator _operator;

        public LogHandler(IOperator operatord)
        {
            _operator = operatord;
        }

        public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            // 记录日志
            await _operator.WriteUserLog(context, next);
        }
    }
}
